package com.whalewire.web.controller;

import java.util.List;
import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.model.LazyDataModel;

import com.whalewire.domain.LogEntry;

@ManagedBean(name="logs")
@ViewScoped
public class Logs {
	
	public String getDummy() {
		return "HELLI HALLI HALLO";
	}

	private LazyDataModel<LogEntry> logEntries;

    private LogEntry selectedLogEntry;

	public Logs() {

		logEntries = new LazyDataModel<LogEntry>() {

			private static final long serialVersionUID = 1L;
			@Override
			public List<LogEntry> load(int first, int pageSize, String sortField, boolean sortOrder, Map<String,String> filters) {

				return LogEntry.findLogEntryEntries(first, pageSize);
			}
		};

		int rowCount = Long.valueOf(LogEntry.countLogEntrys()).intValue();
		logEntries.setRowCount(rowCount);
		System.out.println("Init: "+rowCount);
	}

	
	public LazyDataModel<LogEntry> getLogEntries() {
		return logEntries;
	}


	public void setSelectedLogEntry(LogEntry selectedLogEntry) {
		this.selectedLogEntry = selectedLogEntry;
	}


	public LogEntry getSelectedLogEntry() {
		return selectedLogEntry;
	}

	
}
